class Queue {
  constructor () {
    this.dataStore = []
  }

  /**
   *  入队
   * @param element
   */
  enqueue (element) {
    this.dataStore.push(element)
  }

  /**
   * 出队
   * @returns {*}
   */
  dequeue () {
    return this.dataStore.shift()
  }

  /**
   * 返回第一个元素
   * @returns {*}
   */
  front () {
    return this.dataStore[0]
  }

  /**
   *  返回最后一个元素
   * @returns { * }
   */
  back () {
    return this.dataStore[this.dataStore.length - 1]
  }

  toString () {
    let retStr = ''
    for (let i = 0, len = this.dataStore.length; i < len; i++) {
      retStr += this.dataStore[i] + '\n'
    }
    return retStr
  }

  empty () {
    return this.dataStore.length == 0 ? true : false
  }
}

function print (ele) {
  console.log(ele)
}

var q = new Queue()
q.enqueue('Meredith')
q.enqueue('Cynthia')
q.enqueue('Jennifer')
print(q.toString())
q.dequeue()
print(q.toString())
print('Front of queue: ' + q.front())
print('Back of queue: ' + q.back())
